home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / drgnsmth.cpt / Dragonsmith 1.1 / Base files / Classes / Preferences.h < prev   
Encoding:
C/C++ Source or Header  |  1992-10-03  |  2.0 KB  |  60 lines

  1. /*
  2.     Preferences.h
  3. */
  4.  
  5. #pragma once
  6.  
  7. #include    "FileUtils.h"
  8. #include    "ResourceUtils.h"
  9. #include    "StringUtils.h"
  10.  
  11. #define    eCouldntSavePrefs        1
  12. #define    rPrefsRosterType        'PrRo'
  13. #define    rPrefsRosterID        128
  14.  
  15. typedef struct {
  16.     Handle        resHndl;
  17.     ResType        resType;
  18.     short        resID;
  19.     short        flags;        // This may be used in a future version ╤ leave the low 8 bits alone if you use this field
  20. } PrefsRosterEntry;
  21.  
  22. typedef struct {
  23.     short            refNum;            // RefNum of the file the resources belong to
  24.     short            numRsrcs;        // Number of resources
  25.     PrefsRosterEntry    rsrc[1];
  26. } PrefsRosterList;
  27.  
  28. class Preferences {
  29.  
  30.     protected:
  31.         short            appResFork;            // A refNum to the application's resource fork (must never == -1)
  32.         OSType            fileCreator;            // Signature of the application that created the file
  33.         OSType            fileType;                // The file's type
  34.         PrefsRosterList    **prefsRoster;            // Roster of resource types and IDs ╤ used for resource housekeeping
  35.         short            numPrefs;            // Number of preferences resources
  36.         FSSpec            file;                    // The preferences file
  37.         short            fileResFork;            // A refNum to the file's resource fork (-1 if !fileExists)
  38.         Boolean            fileExists;            // Does the preferences file referred to in this->file exist?
  39.         Boolean            canSaveFile;            // Can we save changes to the file?
  40.         Boolean            usingAppResources;    // Are we using the preferences resources in the application file?
  41.         
  42.     public:
  43.                             Preferences (void);
  44.                             ~Preferences (void);
  45.         virtual Boolean        Init (short appRF, OSType creator, OSType type);
  46.         virtual Boolean        UseFile (FSSpec *fss);
  47.         virtual Handle            GetPrefResource (short index);
  48.         virtual OSErr            DetachPrefResource (short index);
  49.         virtual OSErr            ReleasePrefResource (short index);
  50.         virtual OSErr            SavePrefResource (short index);
  51.         
  52.     protected:
  53.         virtual Boolean        VerifyResources (PrefsRosterList **roster);
  54.         virtual void            CloseFile (void);
  55.         virtual OSErr            CopyPrefs (short destRF);
  56.         virtual PrefsRosterList    **InitPrefsRoster (short refNum);
  57.         virtual Handle            ReadPrefResource (short index);
  58. };
  59.  
  60.